﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.MinStack
{
    class MainProject
    {
        static void Main(string[] args)
        {
            TreeNode treeNode = new TreeNode(3, new TreeNode(9), new TreeNode(20, new TreeNode(15), new TreeNode(17)));
            //Console.WriteLine(MaxDepth(treeNode));
            Console.ReadKey();
        }
        public class MinStack
        {
            private Stack<int> m_Stack;
            public MinStack()
            {
                m_Stack = new Stack<int>();
            }

            public void Push(int val)
            {
                m_Stack.Push(val);
            }

            public void Pop()
            {
                m_Stack.Pop();
            }

            public int Top()
            {
                return m_Stack.Peek();
            }

            public int GetMin()
            {
                if (m_Stack.Count>=1)
                {
                    int value = m_Stack.Peek();
                    foreach (var item in m_Stack)
                    {
                        if (value> item)
                        {
                            value = item;
                        }
                    }
                    return value;
                }
                return 0;
            }
        }
    }
}
